package com.example.project.service.impl;

import com.example.project.dao.ILeavesDao;
import com.example.project.entity.Bussinesstrip;
import com.example.project.entity.Leaves;
import com.example.project.service.ILeavesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LeavesServiceImpl implements ILeavesService {
    @Autowired
    private ILeavesDao leavesDao;

    //实现请假添加方法
    @Override
    public int add(Leaves leaves) {
        return leavesDao.add(leaves);
    }

    //实现查询所有请假数据的方法
    @Override
    public List<Leaves> getAllLeaves(Leaves leaves) {
        return leavesDao.getAllLeaves(leaves);
    }

    //删除请假数据
    @Override
    public int deleteLeaves(Leaves leaves) {
        int leavesValue=0;
        if (leaves.getLeaveId()!=0){
            leavesValue=leavesDao.deleteLeaves(leaves);
        }
        return leavesValue;
    }

    //实现请假信息的更新
    @Override
    public int updateLeaves(Leaves leaves) {
        int   leavesValue=0;
        if (leaves.getLeaveId()!=0){
            leavesValue=leavesDao.updateLeaves(leaves);
        }
        return   leavesValue;
    }

    //实现单挑查询请假数据方法
    @Override
    public Leaves getLeaves(Leaves leaves) {
        Leaves leaves1=new Leaves();
        if(leaves.getLeaveId()!=0){
            leaves1=leavesDao.getLeaves(leaves);
        }
        return leaves1;
    }
}
